package biolabs.model

import biolabs.model.react.Reaction
import biolabs.space.Continuous3DPosition
import biolabs.space.Discrete3DPosition
import biolabs.visual.VisualizationConfiguration

class LiquidEnvironment3D(
	dimensions: Discrete3DPosition,
	diffCoeff: Double,
	substances: Array[Any],
	reactions: Iterable[Reaction]
)
extends LiquidEnvironment[Discrete3DPosition, Continuous3DPosition, Cell.Cell3D](dimensions, diffCoeff, substances, reactions) {

	override def canVisualize[R](config: VisualizationConfiguration[R]) =
		config.get(this).isDefined

	override def visualize[R](config: VisualizationConfiguration[R]) =
		config.get(this) match {
			case Some((visualizers, augmentations)) =>
				val myVis = config.method.combine(
						visualizers map { _.visualize(this) }
				)
				val childVis = config.method.combine(
						getChildren() map { _.visualize(config) } collect {
							case Some(vis) => vis
						}
				)

				// liquid environment defines no child selectors,
				// thus there can be no augmentations
				assert(augmentations == Nil)

				Some(config.method.combine(myVis :: childVis :: Nil))

			case None =>
				None
		}
}
